"""academic URL Configuration

The `urlpatterns` list routes URLs to views. For more information please see:
    https://docs.djangoproject.com/en/2.2/topics/http/urls/
Examples:
Function views
    1. Add an import:  from my_app import views
    2. Add a URL to urlpatterns:  path('', views.home, name='home')
Class-based views
    1. Add an import:  from other_app.views import Home
    2. Add a URL to urlpatterns:  path('', Home.as_view(), name='home')
Including another URLconf
    1. Import the include() function: from django.urls import include, path
    2. Add a URL to urlpatterns:  path('blog/', include('blog.urls'))
"""
from django.conf.urls.static import static
from django.contrib import admin
from django.urls import path, include
from rest_framework.documentation import include_docs_urls
from rest_framework_mongoengine import routers

import authorshow
import foundation
import policy
from academic import settings
from authorshow import tests
from authorshow.views import AuthorViewSet, PaperViewSet, VenueViewSet, CustomAuthToken
from conference import views
from conference.views import StatisticsViewSet, MeetingsViewSet, SubjectsViewSet
from expertwords.views import ExpertWordsViewSet

from foundation.views import FundChinaViewSet, FundEUViewSet, FundUSAViewSet
from fullsearch.views import FullSearchViewSet
from orgswords.views import OrgsWordsViewSet
from policy.views import PolicyViewSet, AwardsGuideViewSet, AwardsViewSet, AwardsDeclarationViewSet, \
    WinningNoticeViewSet, PolicyInterpretionViewSet

router = routers.DefaultRouter()
# TODO 添加 api 接口地址
router.register(r'authors', AuthorViewSet)
router.register(r'papers', PaperViewSet)
router.register(r'venues', VenueViewSet)
router.register(r'fundchina', FundChinaViewSet)
router.register(r'fundEU', FundEUViewSet)
router.register(r'fundUSA', FundUSAViewSet)
router.register(r'policy', PolicyViewSet)
router.register(r'awardsguide', AwardsGuideViewSet)
router.register(r'awards', AwardsViewSet)
router.register(r'declaration', AwardsDeclarationViewSet)
router.register(r'notice', WinningNoticeViewSet)
router.register(r'policyinterpretion', PolicyInterpretionViewSet)
router.register(r'meetings_year', StatisticsViewSet),
router.register(r'conference', MeetingsViewSet),
router.register(r'subject', SubjectsViewSet),
router.register(r'fullsearch', FullSearchViewSet),
router.register(r'expertwords', ExpertWordsViewSet),
router.register(r'orgswords', OrgsWordsViewSet),

urlpatterns = [
    path('admin/', admin.site.urls),
    # authorshow
    path('academic/', include('authorshow.urls')),

    # restful 接口
    path('v1/', include(router.urls)),
    path('v1/api-auth/', include('rest_framework.urls', namespace='rest_framework')),
    path('v1/api-token-auth/', CustomAuthToken.as_view()),
    path('docs/', include_docs_urls(title='Academic API')),  # API 文档接口
    path('meeting_hotspot/', views.keywords_statistics),   # 主题报告热点图
    path('monthly_distribute/', views.meetings_statistics),   # 会议按月分布
    # path('meeting_keywords/', views.meeting_keywords_statistics),    # 各个会议的热点分布
    # path('meeting_org/', views.meeting_org_statistics),    # 各个会议的机构分布图
    path('fund_count/', foundation.views.fund_count),      # 统计各个基金数量
    path('pic_count/', foundation.views.pics_count),       # 统计各个负责人申请基金数
    path('org_count/', foundation.views.orgs_count),       # 统计各个机构申请基金数
    path('second_level/', foundation.views.secondClass_count),   # 统计二级学科申请基金数
    path('third_level/', foundation.views.thirdClass_count),   # 统计三级学科申请基金数

    path('meeting_keywords/', views.meeting_keywords),    # 单个会议的热点分布
    path('meeting_orgs/', views.meeting_orgs),    # 单个会议的机构分布图
    path('policy_hotspot/', policy.views.policy_hotspot),       # 政策热点情况
    path('policy_year/', policy.views.policy_year),        # 政策按年发布情况
    path('policy_source/', policy.views.ploicy_source),    # 政策按文件来源分布情况
    path('awards_year/', policy.views.awards_year),        # 科技奖项由搜索框显示按年获奖情况
    path('awards_name/', policy.views.awards_name),        # 科技奖项由搜索框显示按奖项名称获奖情况
    path('awards_unit/', policy.views.awards_unit),        # 科技奖项由搜索框显示按获奖单位获奖情况
    path('awards_recommendunit/', policy.views.awards_recommendunit),        # 科技奖项由搜索框显示按发布单位/提名推荐单位获奖情况
    path('awards_topical/', policy.views.awards_topical),          # 科技奖项由搜索框显示按研究热点获奖情况
    path('search_policy_year/', policy.views.search_policy_year),        # 政策由搜索框显示按年政策分布情况
    path('search_policy_unit/', policy.views.search_policy_unit),        # 政策由搜索框显示按发布单位政策分布情况
    path('search_policy_province/', policy.views.search_policy_province),        # 政策由搜索框显示按省份的政策分布情况
    path('search_policy_keywords/', policy.views.search_policy_keywords),        # 政策由搜索框显示按关键词的分布情况
    path('author_count/', authorshow.views.author_count),          # 统计专家、机构和学术资源的数量
    path('author_keywords_rank/', authorshow.views.keywords_rank),       # 统计某个作者关键词数据
    path('author_tags_year/', authorshow.views.author_tags_year),        # 统计某个作者研究领域年度发文量
    path('research_year/', authorshow.views.research_year),              # 统计研究热点按年发文量情况
    path('research_year_authors/', authorshow.views.research_authors),   # 统计研究热点每个作者对应发文量情况
    path('research_year_orgs/', authorshow.views.research_orgs),         # 统计研究热点每个机构对应发文量情况
    path('research_year_author/', authorshow.views.research_single_author),         # 统计研究热点单个作者对应发文量情况
    path('policy_orderby_data/', policy.views.policy_orderby_data),      # 搜索的政策按照时间进行排序
    path('policy_orderby_source/', policy.views.policy_orderby_source),  # 搜索的政策按照文件来源进行排序


    # 测试
    path('', tests.test)
]

# 头像: 添加静态路由和路径。
urlpatterns += static(settings.ICON_URL, document_root=settings.ICON_ROOT)
